package com.eric.ipc.aidl;

import android.content.Context;
import android.media.MediaPlayer;

import com.eric.ipc.R;

public class MyMediaPlayer {
	private MediaPlayer mMediaPlayer;
	private static MyMediaPlayer mMyMediaPlayer = null;
	private static Context mContext;
	
	public static MyMediaPlayer getIntance(Context context){
		if(null == mMyMediaPlayer){
			mMyMediaPlayer = new MyMediaPlayer();
		}
		mContext = context;
		return mMyMediaPlayer;
	}
	
	public void play() {
		if(null == mMediaPlayer) {
			mMediaPlayer = MediaPlayer.create(mContext, R.raw.media_volume);
			mMediaPlayer.setLooping(true);
		} else {
			return;
		}
		mMediaPlayer.start();
	}
	
	public void stop(){
		if(mMediaPlayer != null){
			mMediaPlayer.stop();
			mMediaPlayer.release();
			mMediaPlayer = null;
		}
	}
}
